package icasue.stronger.annotation;

import org.springframework.boot.autoconfigure.AutoConfigurationExcludeFilter;
import org.springframework.boot.context.TypeExcludeFilter;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.lang.annotation.*;

/**
 * @Author: Qiao Hang
 * @CreateDate: 2020/9/7 下午4:01
 * @UpdateDate:
 * @Description: This annotation is used for design special components filters,
 * Using on Application's entrance, bu this config, application running choose
 * suitable components to load, and ignore some components which we not expected to reProxy.
 * default exclude Controller, Cause: avoid controller been reProxy, when exist others Aspect logic,
 * Aspect logic will execute twice!
 */
@Target(ElementType.TYPE)
@Inherited
@Documented
@Retention(RetentionPolicy.RUNTIME)
@ComponentScan
public @interface StrongerNoDepend {

    @AliasFor(annotation = ComponentScan.class, attribute = "excludeFilters")
    ComponentScan.Filter[] excludeFilters() default {
            @ComponentScan.Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
            @ComponentScan.Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class),
            @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = {Controller.class, RestController.class})
    };

}
